package aapilast3;

import java.lang.reflect.Constructor;

public class ReflectDemo3 {
    public static void main(String[] args) throws Exception {
        Class<?> cls = Class.forName("aapilast3.Person");
        Constructor<?> c = cls.getConstructor();
        Object obj = c.newInstance();
        System.out.println(obj);

        Constructor<?> c1 = cls.getConstructor(String.class, int.class);
        Object obj1 = c1.newInstance("李四", 20);
        System.out.println(obj1);

        Constructor<?> c2 = cls.getDeclaredConstructor(String.class);
        Object obj2 = c2.newInstance("王五");
        System.out.println(obj2);
    }
}
